<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      img {
        width: 120px;
        height: 120px;
      }
    </style>
    <script src="./js/jquery-3.6.0.js"></script>
  </head>
  <body>
    <img src="./images/1.jpg" alt="这是一张美女图片" />
    <hr />
    <button>attr设置src属性</button>
    <button>attr移除src属性</button>
    <button>prop设置src属性</button>
    <button>prop移除src属性</button>
  </body>
</html>
<script>
  $('button:eq(0)').click(function () {
    $('img').attr('src', './images/1.jpg')
  })

  $('button:eq(1)').click(function () {
    $('img').removeAttr('src')
  })

  $('button:eq(2)').click(function () {
    $('img').prop('src', './images/1.jpg')
  })

  $('button:eq(3)').click(function () {
    $('img').prop('src', '')
  })
</script>
